# -*- coding: utf-8 -*-
from datetime import timedelta
from jms.dwd.dwd_warhouse.dwd_wide_sign_summary_waybill_dt import jms_dwd__dwd_wide_sign_summary_waybill_dt
from jms.dim.dim_network_whole_massage import jms_dim__dim_network_whole_massage
from jms.dwd.oms.dwd_yl_oms_order_mark_expand_base_dt import jms_dwd__dwd_yl_oms_order_mark_expand_base_dt
from jms.dwd.oms.dwd_yl_oms_order_delivery_record_base_dt import jms_dwd__dwd_yl_oms_order_delivery_record_base_dt
from jms.dwd.sqs.dwd_sqs_call_record_base_dt import jms_dwd__dwd_sqs_call_record_base_dt
from utils.operators.cluster_for_spark_sql_operator import SparkSqlOperator

jms_dm__dm_cusc_demand_sign_taking_call_detail_dt = SparkSqlOperator(
    task_id='jms_dm__dm_cusc_demand_sign_taking_call_detail_dt',
    email=['shenjiaming@jtexpress.com', 'yl_bigdata@yl-scm.com'],
    pool_slots=5,
    master='yarn',
    name='jms_dm__dm_cusc_demand_sign_taking_call_detail_dt{{ execution_date | cst_ds_nodash }}',
    sql='jms/dm/dm_cusc_demand_sign_taking_call_detail_dt/execute.hql',
    driver_memory='3G' , 
    executor_memory='3G' , 
    executor_cores=2 , 
    num_executors=5 , 
    yarn_queue='pro',
    conf={'spark.dynamicAllocation.enabled': 'true',  # 动态资源开启
          'spark.shuffle.service.enabled': 'true',  # 动态资源 Shuffle 服务开启
        'spark.dynamicAllocation.maxExecutors'             : 6 , 
          'spark.dynamicAllocation.cachedExecutorIdleTimeout': 60,  # 动态资源自动释放闲置 Executor 的超时时间(s)
          'spark.sql.sources.partitionOverwriteMode': 'dynamic',  # 允许删改已存在的分区
        'spark.executor.memoryOverhead'             : '2G' , 
          },
    hiveconf={'hive.exec.dynamic.partition': 'true',
              'hive.exec.dynamic.partition.mode': 'nonstrict',
              'hive.exec.max.dynamic.partitions.pernode': 5000,
              'hive.exec.max.dynamic.partitions': 30000
              },
    execution_timeout=timedelta(minutes=60),
    retries=2,
    sla=timedelta(hours=3),
)

jms_dm__dm_cusc_demand_sign_taking_call_detail_dt << [jms_dwd__dwd_wide_sign_summary_waybill_dt,
                                                      jms_dim__dim_network_whole_massage
    , jms_dwd__dwd_yl_oms_order_mark_expand_base_dt
    , jms_dwd__dwd_yl_oms_order_delivery_record_base_dt
    , jms_dwd__dwd_sqs_call_record_base_dt
                                                      ]
